package iterator.main.person;

import iterator.main.iterator.Iterator;
import iterator.main.iterator.PersonIterator;

import java.util.ArrayList;
import java.util.Random;

public class PersonList implements IPersonList {
    //存储用户信息列表
    private ArrayList<IPerson> list = new ArrayList<>();

    public PersonList() {
        Random random = new Random();
        //创建人员信息
        for (int i = 0; i < 10; i++) {
            IPerson person = new Person("人员" + i, random.nextInt(30), random.nextInt(2));
            this.list.add(person);
        }
    }

    /**
     * 获取内部存储人员信息内容
     */
    @Override
    public ArrayList<IPerson> getPersonList() {
        return this.list;
    }

    /**
     * 迭代器
     */
    @Override
    public Iterator iterator() {
        return new PersonIterator(this.list);
    }
}
